#include "view.h"
#include "scene.h"
#include <QApplication>
#include <QFontDatabase>
#include <QObject>
#include <QScreen>

int main(int argc, char *argv[])
{
    QApplication a(argc, argv);

    QString fontPath = ":/fonts/GlacialIndifference-Bold.otf";
    QFontDatabase::addApplicationFont(fontPath);

    Scene scene(0, 0, 1381, 889);
    View view(&scene);
    QObject::connect(&scene, &Scene::windowMoved, &view, &View::slotMoved);
    QObject::connect(&scene, &Scene::scaleFactorChanged, &view, &View::resizeFactorChanged);
    QObject::connect(&scene, &Scene::exitClicked, &a, &QApplication::quit);
    view.setViewportUpdateMode(QGraphicsView::BoundingRectViewportUpdate);
    view.setCacheMode(QGraphicsView::CacheBackground);
    view.setRenderHints(QPainter::Antialiasing | QPainter::SmoothPixmapTransform);

    QScreen *screen = a.primaryScreen();
    QRect rect = screen->geometry();
    view.move(rect.center() - QPoint(1381 / 2, 889 / 2));
    view.show();
    return a.exec();
}
